package flatlandRPGTest;

import flatlandRPG.GameState.DuplicateEventException;
import flatlandRPG.GameState;
import student.*;

// -------------------------------------------------------------------------
/**
 *  Tests the game state class.
 *
 *  @author evan
 *  @version May 1, 2011
 */
public class GameStateTest
    extends TestCase
{
    private GameState testState;


    public void setUp()
    {
        testState = new GameState();
    }


    // ----------------------------------------------------------
    /**
     * Tests that adding an event properly adds it.
     */
    public void testEvent()
    {
        assertFalse(testState.eventOccured("Some Event"));

        testState.addEvent("Some Event");

        assertTrue(testState.eventOccured("Some Event"));
    }


    // ----------------------------------------------------------
    /**
     * Tests that adding the same event more than once throws an exception.
     */
    public void testAddMultipleEvents()
    {
        testState.addEvent("Some Event");
        Exception occured = null;
        try
        {
            testState.addEvent("Some Event");
        }
        catch (Exception exception)
        {
            occured = exception;
        }
        assertNotNull(occured);
        assertTrue(occured instanceof DuplicateEventException);
        assertEquals("This event has already been added", occured.getMessage());
    }
}
